package cm309.BookingSystem.web;

import java.io.IOException;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cm309.BookingSystem.tm.web.servlet.CreateBKAction;
import cm309.BookingSystem.tm.web.servlet.CreateTMAction;
import cm309.BookingSystem.tm.web.servlet.DeleteTMAction;
import cm309.BookingSystem.tm.web.servlet.ReadBKAction;
import cm309.BookingSystem.tm.web.servlet.ReadTMAction;
import cm309.BookingSystem.tm.web.servlet.ReadTTAction;
import cm309.BookingSystem.tm.web.servlet.UpdateBKAction;
import cm309.BookingSystem.tm.web.servlet.UpdateTMAction;
import cm309.BookingSystem.web.servlet.MemberController;

/**
 * Servlet implementation class ActionServlet
 */
public class ActionServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	Map<String, Action> actions= new HashMap<String, Action>();
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ActionServlet() {
        super();
        actions.put("TM/CreateTM", new CreateTMAction());
        actions.put("TM/ReadTM", new ReadTMAction());
        actions.put("TM/UpdateTM", new UpdateTMAction());
        actions.put("TM/DeleteTM", new DeleteTMAction());
        actions.put("TM/CreateBK", new CreateBKAction());
        actions.put("TM/ReadBK", new ReadBKAction());
        actions.put("TM/UpdateBK", new UpdateBKAction());
        actions.put("TM/ReadTT", new ReadTTAction());
       
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		actions.get(request.getPathInfo().substring(1)).execute(request, response);
	}

}
